home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earkit / news / thor / rexx / fse / findfile.fse < prev    next >
Text File  |  1998-05-24  |  3KB  |  136 lines

  1. /* FindFiles.fse by Troels Walsted Hansen
  2. ** With searchcode by Eivind Nordseth
  3. ** $VER: FindFiles.fse 1.11 (21.11.94)
  4. **
  5. ** An ARexx script that finds files matching a search pattern on
  6. ** a chosen bbs and inserts the file information into the FSE
  7. ** you are currently using.
  8. */
  9.  
  10. options results
  11.  
  12. /* needs FSE, THOR and bbsread.library functions */
  13.  
  14. if(substr(address(),1,8) ~= "THOR_FSE") then
  15. do
  16.     say "This script should only be started from inside the FSE."
  17.     exit 20
  18. end
  19. else fseport = address()
  20.  
  21. p = ' ' || address() || ' ' || show('P',,)
  22. thorport = pos(' THOR.',p)
  23.  
  24. if thorport > 0 then thorport = word(substr(p,thorport+1),1)
  25. else
  26. do
  27.     say 'No THOR port found!'
  28.     exit 10
  29. end
  30.  
  31. if ~show('p', 'BBSREAD') then
  32. do
  33.     address command
  34.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  35.         "WaitForPort BBSREAD"
  36. end
  37.  
  38. /* get bbsname */
  39.  
  40. address (bbsread)
  41. GETBBSLIST stem BBSLIST
  42. if(rc ~= 0) then
  43. do
  44.     address(thorport)
  45.     REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
  46.     exit 5
  47. end
  48.  
  49. address(thorport)
  50. THORTOFRONT
  51.  
  52. REQUESTLIST instem BBSLIST title '"Select BBS:"' SIZEGADGET
  53. if(rc ~= 0) then exit
  54. else bbs = result
  55.  
  56. /* get searchpattern */
  57.  
  58. REQUESTSTRING TITLE '"Please enter search pattern:"' BT '"_Ok|_Cancel"' MAXCHARS 100
  59. pattern = result
  60. if(rc ~= 0 | pattern = "") then exit
  61.  
  62. address (bbsread)
  63. SEARCHBRFILE bbsname '"' || bbs || '"' stem SRESULT search '"' || pattern || '"' keyword
  64.  
  65. if(result > 0) then
  66. do
  67.     do f=1 to SRESULT.FILEAREA.COUNT
  68.         address(fseport)
  69.         INSERTSTRING '0a'x || '(' || SRESULT.FILEAREA.f || ')' || '0a'x
  70.  
  71.         do i=1 to SRESULT.FILE.f.COUNT
  72.             call showfiledata('"' || bbs || '"', '"'|| SRESULT.FILEAREA.f || '"', SRESULT.FILE.f.i, fseport)
  73.         end
  74.     end
  75. end
  76. else
  77. do
  78.     address(fseport)
  79.     INSERTSTRING 'No files found.' || '0a'x
  80. end
  81.  
  82. exit
  83.  
  84. /* Procedure to show the data about a file */
  85.  
  86. showfiledata: procedure
  87.     parse arg bbs,farea,filenr,fseport
  88.  
  89.     FDF_DELETED = '00000001'x
  90.  
  91.     drop FILE.    /* Important */
  92.  
  93.     address (bbsread)
  94.     READBRFILE bbs farea filenr tagsstem FILE datastem DATA
  95.  
  96.     nextfile = result
  97.  
  98.     if (bitand(DATA.FLAGS,FDF_DELETED) ~= FDF_DELETED) then
  99.     do
  100.         if(symbol("FILE.DATE") = "VAR") then fdate = FILE.DATE
  101.         else date = DATA.FILEDATE
  102.  
  103.         AMIGA2DATE fdate CD
  104.         fdatestr = right(CD.YEAR, 2) || right('0'||CD.MONTH, 2) || right('0'||CD.MDAY, 2)
  105.  
  106.         if(symbol("FILE.SIZE") = "VAR") then fsize = FILE.SIZE
  107.         else size = "Unkn"
  108.  
  109.         if(symbol("FILE.DOWNLOADS") = "VAR") then fdnls = FILE.DOWNLOADS
  110.         else fdnls = "Unkn"
  111.  
  112.         if(symbol("FILE.DESCRIPTION.COUNT") = "VAR") then descr = FILE.DESCRIPTION.1
  113.         else descr = "NONE"
  114.  
  115.         address(fseport)
  116.         INSERTSTRING left(FILE.NAME,16) || " " || fdatestr || " " || right(fsize,7) || right(fdnls,4) || " " || descr || '0a'x
  117.  
  118.         if(descr ~= "NONE") then
  119.         do
  120.             if(FILE.DESCRIPTION.COUNT > 1) then
  121.             do
  122.                 do n=2 to FILE.DESCRIPTION.COUNT
  123.                     address(fseport)
  124.                     INSERTSTRING left("",33) || FILE.DESCRIPTION.n || '0a'x
  125.                 end
  126.             end
  127.         end
  128.     end
  129.     else
  130.     do
  131.         address(fseport)
  132.         INSERTSTRING 'File is deleted.' || '0a'x
  133.     end
  134.  
  135.     return nextfile
  136.